/*-------------------------------------------------------------------------

***************** Modification History ***********************************
   @doc
   @module modem.h - Prototype file for Modem communications |
   @end
   
$Log:  $ 
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/

#ifndef VSMODEM_H
#define VSMODEM_H

#include <define.h>
#include <mdmdefs.h>
#include <comm.h>
#include <cpt.h>

#ifdef MODEM

#define MODEM_RESP_TO       3

typedef struct modem_struct
{
	int hModem;             /* Handle of the modem, local to this file */
	int inModemOpen;
	int inCurrentLine;      /* Primary or Secondary Line */
	int inCPTIndex;
	short shSyncResultCode;
	int inDialAttempts[MAX_DIAL_LINES];
	VS_BOOL fNoPhoneNumber[MAX_DIAL_LINES];
	CPT_REC srCPT;

	void (*vdGetPriAuthPhoneNumber)(char *, CPT_REC);
	void (*vdGetSecAuthPhoneNumber)(char *, CPT_REC);
	void (*vdGetPriSettlePhoneNumber)(char *, CPT_REC);
	void (*vdGetSecSettlePhoneNumber)(char *, CPT_REC);
	short (*shGetModemMode)(CPT_REC);
	void (*vdGetModemParam)(char *, CPT_REC);
	short (*shGetBaudRate)(CPT_REC);
	short (*shGetDataFormat)(CPT_REC);
	short (*shGetNumOfTries)(CPT_REC);
	long (*lnGetRedialDelay)(CPT_REC);
	long (*lnGetMultiTransDelay)(CPT_REC);
	short (*shGetCarrierTimeOut)(CPT_REC);
	short (*shGetRespTimeOut)(CPT_REC);
	short (*shGetInterCharTO)(CPT_REC);
	short (*shGetSyncSwitchDelay)(CPT_REC);
	char* (*szGetPABXCode)(void);
	void (*vdGet3101HostAddr)(char *, CPT_REC);
	VS_BOOL (*fGetReconnect)(CPT_REC);
	VS_BOOL (*fGetModemFastConnect)(CPT_REC);
	VS_BOOL (*fGetCommType)(CPT_REC);
	VS_BOOL (*fGetBlindDial)(CPT_REC);
	VS_BOOL (*fGetDialType)(CPT_REC);
	VS_BOOL (*fGet3101CommType)(CPT_REC);

	void (*vdSetPriAuthPhoneNumber)(char *, void *);
	void (*vdSetSecAuthPhoneNumber)(char *, void *);
	void (*vdSetPriSettlePhoneNumber)(char *, void *);
	void (*vdSetSecSettlePhoneNumber)(char *, void *);
	void (*vdSetModemMode)(short, void *);
	void (*vdSetModemParam)(char *, void *);
	void (*vdSetBaudRate)(short, void *);
	void (*vdSetDataFormat)(short, void *);
	void (*vdSetNumOfTries)(short, void *);
	void (*vdSetRedialDelay)(long, void *);
	void (*vdSetMultiTransDelay)(long, void *);
	void (*vdSetCarrierTimeOut)(short, void *);
	void (*vdSetRespTimeOut)(short, void *);
	void (*vdSetInterCharTO)(short, void *);
	void (*vdSetSyncSwitchDelay)(short, void *);
	void (*vdSetPABXCode)( const char *);
	void (*vdSet3101HostAddr)(char *, void *);
	void (*vdSetReconnect)(VS_BOOL, void *);
	void (*vdSetModemFastConnect)(VS_BOOL, void *);
	void (*vdSetCommType)(VS_BOOL, void *);
	void (*vdSetBlindDial)(VS_BOOL, void *);
	void (*vdSetDialType)(VS_BOOL, void *);
	void (*vdSet3101CommType)(VS_BOOL, void *);

} MODEM_OBJECT;

int inSetModemObjectFunctions(MODEM_OBJECT *obModem);
int inDefaultSetModemObjectFunctions(MODEM_OBJECT *obModem);
void vdInitializeModemComm (COMM_OBJECT *obCommunication);
int inInitModemCommunication (COMM_OBJECT *obCommunication);
int inOpenModemCommunication (COMM_OBJECT *obCommunication, int inOpCode);
int inBeginModemCommunication (COMM_OBJECT *obCommunication, int inCPTIndex, VS_BOOL fUsePrimaryLine);
int inCheckModemCommunication (COMM_OBJECT *obCommunication);
int inSendModemCommunication (COMM_OBJECT *obCommunication, char *pchSendBuff, int inSendSize, VS_BOOL fConfirmSend, int inTimeout, long lnMessage);
int inReceiveModemCommunication (COMM_OBJECT *obCommunication, char *pchReceiveBuff, int inReceiveSize, int inReceiveTimeout, long lnMessage);
int inFlushModemCommunication (void);
int inEndModemCommunication (COMM_OBJECT *obCommunication);
int inDeInitModemCommunication (COMM_OBJECT *obCommunication);
int inInitModemEnvironmentParam (MODEM_OBJECT *obModem);
int inDefaultBaseInitModemEnvParam (MODEM_OBJECT *obModem);
int inDefaultASPENInitModemEnvParam (MODEM_OBJECT *obModem);
int inDefaultTDKInitModemEnvParam (MODEM_OBJECT *obModem);
int inDefaultPREDATORInitModemEnvParam (MODEM_OBJECT *obModem);

int inDefaultASPENInitModemEnvParam (MODEM_OBJECT *obModem);

int inProcessPortError (COMM_OBJECT *obCommunication, int inErr);
void vdDispLineDialing( int inCurrLine );
int inGetPhoneNumber(MODEM_OBJECT *obModem, char *szPhoneNumber, int inCode);
int inModemDial (COMM_OBJECT *obCommunication, int inCPTIndex, VS_BOOL fUsePrimaryLine);

int inSyncDialTask (MODEM_OBJECT *obModem, int inOpCode, VS_BOOL fAbort);

#endif /* MODEM */

#endif

